package top.fengleifeng.question;

import java.math.BigDecimal;
import top.fengleifeng.util.Constants;

/**
 * @author : fengelfeing
 * @version V1.0
 * @Project: leetcode-test
 * @Package : top.fengleifeng.question
 * @Description:
 * @Date: 2020年11月16日5:55 下午
 */
public class Num1037有效的回旋镖 {
    //y=kx+l;

    /**
     * 1=k+l; 2=3k+l;  oneY = k * oneX+l; 3=2k+l; oneY = k * oneX+l; twoY = k* twoX+l; oney-twoy/onex-twox =
     */
    class Solution {
//
//        public boolean isBoomerang(int[][] points) {
//
//            int oneX = points[0][0];
//            int oneY = points[0][1];
//
//            int twoX = points[1][0];
//            int twoY = points[1][1];
//
//            int threeX = points[2][0];
//            int threeY = points[2][1];
//
//            BigDecimal oneXBig = new BigDecimal(oneX);
//            BigDecimal oneYBig = new BigDecimal(oneY);
//            BigDecimal twoXBig = new BigDecimal(twoX);
//            BigDecimal twoYBig = new BigDecimal(twoY);
//            BigDecimal threeXBig = new BigDecimal(threeX);
//            BigDecimal threeYBig = new BigDecimal(threeY);
//            BigDecimal first = oneXBig.subtract(twoXBig);
//            BigDecimal second = oneYBig.subtract(twoYBig);
//
//            BigDecimal first2 = oneXBig.subtract(threeXBig);
//            BigDecimal second2 = oneYBig.subtract(threeYBig);
//            if(first.compareTo(new BigDecimal(0))==0){
//                if(first2.compareTo(new BigDecimal(0))==0){
//                    return false;
//                }else{
//                    return true;
//                }
//            }
//            if(first2.compareTo(new BigDecimal(0))==0){
//                if(first.compareTo(new BigDecimal(0))==0){
//                    return false;
//                }else{
//                    return true;
//                }
//            }
//            BigDecimal third = second.divide(first).setScale(10, BigDecimal.ROUND_HALF_UP);
//            BigDecimal third2 = second2.divide(first2).setScale(10, BigDecimal.ROUND_HALF_UP);
//            if (third2.compareTo(third) == 0) {
//                return false;
//            }
//            return true;
//        }
        public boolean isBoomerang(int[][] points){
            return (points[1][1] - points[0][1]) * (points[2][0] - points[0][0]) != (points[2][1] - points[0][1]) * (points[1][0] - points[0][0]);
        }
    }

    public static void main(String[] args) {
//        int[][] ints = new int[][]{{1, 1}, {2, 3}, {3, 2}};
//        int[][] ints = new int[][]{{0, 0}, {2, 1}, {0, 2}};
        int[][] ints = new int[][]{{0, 1}, {0, 1}, {2, 1}};
        Constants.printArrs(ints);
        boolean boomerang = new Num1037有效的回旋镖().new Solution().isBoomerang(ints);
        System.out.println(boomerang);
    }
}
